#!/bin/bash

#Copyright 2024 Institute of Software, Chinese Academy of Sciences.
#Licensed under the Apache License, Version 2.0 (the "License");
#you may not use this file except in compliance with the License.
#You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
#Unless required by applicable law or agreed to in writing, software
#distributed under the License is distributed on an "AS IS" BASIS,
#WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#See the License for the specific language governing permissions and
#limitations under the License.

OHOS_IMG="out/arm_virt/packages/phone/images"
sudo qemu-system-arm \
-M virt \
-smp 6 \
-m 4096 \
-kernel ${OHOS_IMG}/zImage \
-initrd ${OHOS_IMG}/ramdisk.img \
-nographic \
-vga none \
-device virtio-gpu-pci,xres=480,yres=320 \
-vnc :21 \
-display sdl,gl=off \
-device virtio-mouse-pci \
-device virtio-keyboard-pci \
-k en-us \
-rtc base=localtime,clock=host \
-device es1370 \
-bios edk2-arm-code.fd \
-netdev bridge,id=net0,br=virbr0 -device virtio-net-device,netdev=net0,mac=12:22:33:44:55:66 \
-drive if=none,file=${OHOS_IMG}/userdata.img,format=raw,id=userdata,index=5 -device virtio-blk-device,drive=userdata \
-drive if=none,file=${OHOS_IMG}/chip_prod.img,format=raw,id=chip_prod,index=4 -device virtio-blk-device,drive=chip_prod \
-drive if=none,file=${OHOS_IMG}/sys_prod.img,format=raw,id=sys_prod,index=3 -device virtio-blk-device,drive=sys_prod \
-drive if=none,file=${OHOS_IMG}/vendor.img,format=raw,id=vendor,index=2 -device virtio-blk-device,drive=vendor \
-drive if=none,file=${OHOS_IMG}/system.img,format=raw,id=system,index=1 -device virtio-blk-device,drive=system \
-drive if=none,file=${OHOS_IMG}/updater.img,format=raw,id=updater,index=0 -device virtio-blk-device,drive=updater \
-append "loglevel=7 ip=dhcp console=tty0,115200 console=ttyAMA0,115200 init=/bin/init ohos.boot.hardware=virt root=/dev/ram0 rw ohos.required_mount.system=/dev/block/vdb@/usr@ext4@ro,barrier=1@wait,required ohos.required_mount.vendor=/dev/block/vdc@/vendor@ext4@ro,barrier=1@wait,required ohos.required_mount.data=/dev/block/vdf@/data@ext4@nosuid,nodev,noatime,barrier=1,data=ordered,noauto_da_alloc@wait,reservedsize=104857600"
